<?php

/**
 * This is the model class for table "{{enterprise}}".
 *
 * The followings are the available columns in table '{{enterprise}}':
 * @property integer $id
 * @property string $nom
 * @property string $groupe
 * @property string $rue1
 * @property string $rue2
 * @property string $ville
 * @property string $cp
 * @property string $pays
 * @property string $tel
 * @property string $rh_prenom
 * @property string $rh_nom
 * @property string $rh_contact
 * @property string $lieu_groupe
 * @property string $lieu_rue1
 * @property string $lieu_rue2
 * @property string $lieu_ville
 * @property string $lieu_cp
 * @property string $lieu_pays
 * @property string $lieu_tel
 *
 * The followings are the available model relations:
 * @property Stage[] $stages
 */
class Enterprise extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Enterprise the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{enterprise}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nom, groupe, rue1, rue2, ville, cp, pays, tel, rh_nom, rh_contact, lieu_groupe, lieu_rue1, lieu_rue2, lieu_ville, lieu_cp, lieu_pays, lieu_tel', 'length', 'max'=>45),
			array('rh_prenom', 'length', 'max'=>30),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, nom, groupe, rue1, rue2, ville, cp, pays, tel, rh_prenom, rh_nom, rh_contact, lieu_groupe, lieu_rue1, lieu_rue2, lieu_ville, lieu_cp, lieu_pays, lieu_tel', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'stages' => array(self::HAS_MANY, 'Stage', 'enterprise_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nom' => 'Nom',
			'groupe' => 'Groupe',
			'rue1' => 'Rue1',
			'rue2' => 'Rue2',
			'ville' => 'Ville',
			'cp' => 'Cp',
			'pays' => 'Pays',
			'tel' => 'Tel',
			'rh_prenom' => 'Rh Prenom',
			'rh_nom' => 'Rh Nom',
			'rh_contact' => 'Rh Contact',
			'lieu_groupe' => 'Lieu Groupe',
			'lieu_rue1' => 'Lieu Rue1',
			'lieu_rue2' => 'Lieu Rue2',
			'lieu_ville' => 'Lieu Ville',
			'lieu_cp' => 'Lieu Cp',
			'lieu_pays' => 'Lieu Pays',
			'lieu_tel' => 'Lieu Tel',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('nom',$this->nom,true);
		$criteria->compare('groupe',$this->groupe,true);
		$criteria->compare('rue1',$this->rue1,true);
		$criteria->compare('rue2',$this->rue2,true);
		$criteria->compare('ville',$this->ville,true);
		$criteria->compare('cp',$this->cp,true);
		$criteria->compare('pays',$this->pays,true);
		$criteria->compare('tel',$this->tel,true);
		$criteria->compare('rh_prenom',$this->rh_prenom,true);
		$criteria->compare('rh_nom',$this->rh_nom,true);
		$criteria->compare('rh_contact',$this->rh_contact,true);
		$criteria->compare('lieu_groupe',$this->lieu_groupe,true);
		$criteria->compare('lieu_rue1',$this->lieu_rue1,true);
		$criteria->compare('lieu_rue2',$this->lieu_rue2,true);
		$criteria->compare('lieu_ville',$this->lieu_ville,true);
		$criteria->compare('lieu_cp',$this->lieu_cp,true);
		$criteria->compare('lieu_pays',$this->lieu_pays,true);
		$criteria->compare('lieu_tel',$this->lieu_tel,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}